package com.zcx.liu_zi_qi

object Map {
    var map= Array<Array<Int>>(4,{it -> Array<Int>(4,{it -> 0})})//4X4数组.0:空,1:白子,2:黑子
    var list = arrayListOf<ChessBoard.ChessMan>()//list集合存储棋子数据
    val gameModel=GameModel.RENJI//游戏模式
    var whoChess=ChessManType.WHITE//轮到哪方下子
    var history= arrayListOf<Pair<ArrayList<ChessBoard.ChessMan>,Array<Array<Int>>>>()//记录历史信息

    fun copyMap(m: Array<Array<Int>> = map):Array<Array<Int>>{
        val temp=Array<Array<Int>>(4,{it -> Array<Int>(4,{it -> 0})})
        for (i in 0..3){
            for (j in 0..3) {
                temp[i][j]=m[i][j]
            }
        }
        return temp
    }

    fun copyList(l: ArrayList<ChessBoard.ChessMan> = list):ArrayList<ChessBoard.ChessMan>{
        val temp=ArrayList<ChessBoard.ChessMan>()
        l.forEach {
            temp.add(it.copy())
        }
        return temp
    }
    /**
     * 打印Map信息
     */
    fun printMap(m: Array<Array<Int>> = map){
        print("[")
        for (i in 0..3){
            print("[")
            for (j in 0..3) {
                if (j == 3) {
                    print("${m[i][j]}")
                } else {
                    print("${m[i][j]},")
                }
            }
            print("]")

        }
        println("]")
    }

    /**
     * 打印List信息
     */
    fun printList(l: ArrayList<ChessBoard.ChessMan> = list){
        print("[")
        l.forEach {
            print(it.toString())
        }
        println("]")
    }
}